﻿namespace PokerSimulator
{
	public static class HandValue
	{
		public static string GetDescription(Hand hand)
		{
			const string emptyHand = "Empty Hand";
			if (hand == null)
			{
				return emptyHand;
			}
			int count = hand.CardCount;
			if (count == 0)
			{
				return emptyHand;
			}
			if (count == 2)
			{
				return hand.Description;
			}

			string translatedMoneyCard = Card.ConvertToCardName((int)hand.MoneyCard);
			double handValue = hand.Value;
			if (handValue >= Minimum.StraightFlush)
			{
				return Card.ConvertToCardName(hand.HighCardInStraight) + " High Straight Flush";
			}
			if (handValue >= Minimum.FourOfAKind)
			{
				return "Four " + translatedMoneyCard + "s";
			}
			if (handValue >= Minimum.FullHouse)
			{
				int[] fullhouse = hand.GetFullHouse();
				return Card.ConvertToCardName(fullhouse[0]) + "s full of " + Card.ConvertToCardName(fullhouse[1]) + "s";
			}
			if (handValue >= Minimum.Flush)
			{
				return translatedMoneyCard + " High Flush";
			}
			if (handValue >= Minimum.Straight)
			{
				return translatedMoneyCard + " High Straight";
			}
			if (handValue >= Minimum.ThreeOfAKind)
			{
				return "Three " + translatedMoneyCard + "s";
			}
			if (handValue >= Minimum.TwoPair)
			{
				int[] twoPair = hand.GetTwoPair();
				string top = Card.ConvertToCardName(twoPair[0]);
				string bottom = Card.ConvertToCardName(twoPair[1]);
				return "Two Pair: " + top + "s and " + bottom + "s";
			}
			if (handValue >= Minimum.Pair)
			{
				return "Pair of " + translatedMoneyCard + "s";
			}
			if (handValue >= 6)
			{
				return translatedMoneyCard + " High";
			}
			return emptyHand; // should never get here
		}

		#region Nested type: Minimum

		internal static class Minimum
		{
			internal const int Flush = 40000;
			internal const int Fold = 0;
			internal const int FourOfAKind = 900000;
			internal const int FullHouse = 120000;
			internal const int HighCard = 6;
			internal const int Pair = 34;
			internal const int Straight = 12500;
			internal const int StraightFlush = 50000000;
			internal const int ThreeOfAKind = 1600;
			internal const int TwoPair = 250;
		}

		#endregion

		#region Nested type: Scalar

		internal static class Scalar
		{
			internal const int Flush = 8000;
			internal const int FourOfAKind = 450000;
			internal const int FullHouse = 60000;
			internal const int Pair = 17;
			internal const int Straight = 2500;
			internal const int StraightFlush = 10000000;
			internal const int ThreeOfAKind = 800;
			internal const int TwoPair = 50;
		}

		#endregion
	}
}